#ifndef _NFC_HAL_DEBUG_H_
#define _NFC_HAL_DEBUG_H_

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>

#include "nfc_hal_transfer.h"

#define NFC_DEBUG_HEAD                  0x81

/* 兼容旧版软件包格式 */
#define HEAD                            0x68

extern uint8_t *cmdp;

typedef struct r_w_reg_s {
    uint8_t addr;          //读写寄存器地址
    uint8_t rw_dat;        //读写寄存器值
} r_w_reg;


typedef struct reg_pkt_s {
    uint8_t addr;
    uint8_t reg_value;
    uint8_t page;

} reg_pkt_s;

typedef struct pc_tx_pkt_s {
    uint8_t head;          //包头
    uint8_t len;           //包长：从包头到校验和
    uint8_t cmd;           //包命令

    union datu {
        r_w_reg reg;
        uint8_t dat[1];    //发送或接收的数据
    } datu;
} pc_tx_pkt;

extern bool debug_cmd_vild;

#define CMD_MSG_MAX		128
typedef struct
{
    uint8_t start;
    uint8_t index;
    uint8_t msg_len;
    uint8_t msg[CMD_MSG_MAX];
} sCmdTypeDef;



void hal_debug_cmd_recv_handler(uint8_t ch);

void make_packet(uint8_t cmd, uint8_t *buf, uint8_t len);
void hal_debug_cmd_read(void (*func)(void *pkt));
#endif
